package com.j.lemon.learn.basic.practice;

import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.ClassPathXmlApplicationContext;

@Configuration
public class BeanTest {
    @Bean(initMethod = "ini",name = "st")
    public Studen getBean(){
        System.out.println("st被创建");
        return new Studen();
    }

    public static void main(String[] args) {
        ApplicationContext context = new ClassPathXmlApplicationContext("spring/spring-context.xml");
        Studen studen = context.getBean(Studen.class);
        System.out.println(studen.getName());
        System.out.println(studen.getId());

        Role role = context.getBean(Role.class);
        System.out.println(role.getName());
        System.out.println(role.getStuden().random);
    }

}
